<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>Nginx 中文文档 - Module ngx_stream_upstream_module | Docs4dev</title>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="Nginx (engine x) 是一个高性能的HTTP和反向代理服务，也是一个IMAP/POP3/SMTP服务。">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="true">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta property="og:type" content="website">
<meta property="og:title" content="Nginx 中文文档 - Module ngx_stream_upstream_module">
<meta property="og:url" content="https://www.docs4dev.com/docs/zh/nginx/current/reference/stream-ngx_stream_upstream_module.html">
<meta property="og:site_name" content="Docs4dev">
<meta property="og:locale" content="zh_CN">
<meta name="twitter:card" content="Nginx (engine x) 是一个高性能的HTTP和反向代理服务，也是一个IMAP/POP3/SMTP服务。">
<meta name="generator" content="Docs4dev template engine">
<link rel="stylesheet" href="static/css/app.min.css">
<link rel="shortcut icon" href="https://www.docs4dev.com/static/images/favicon.ico" type="image/x-icon">
<script async="" src="static/js/js.js"></script>
<script async="" src="static/js/adsbygoogle.js" crossorigin="anonymous"></script>
<script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }

    gtag('js', new Date());
    gtag('config', 'UA-129571937-1');
  </script>
<link rel="amphtml" href="https://www.docs4dev.com/amp/docs/zh/nginx/current/reference/stream-ngx_stream_upstream_module.html">
<script type="application/ld+json">{"name":null,"headline":"Nginx 中文文档-Module ngx_stream_upstream_module","inLanguage":"zh-CN","version":"current","image":"/static/icon/icon-nginx.svg","datePublished":"2021-05-20T12:51:01Z","dateCreated":"2021-05-20T12:51:01Z","dateModified":"2021-07-07T12:48:29Z","@context":"https://schema.org/","@type":"APIReference","abstract":"Nginx (engine x) 是一个高性能的HTTP和反向代理服务，也是一个IMAP/POP3/SMTP服务。"}</script>
</head>
<body>
<div class="book with-summary">
<div class="book-summary">
<div class="logo">
<a href="index.html" style="color: inherit;">
<img src="static/picture/icon-nginx.svg" style="width: 48px; height: 48px;" alt="Logo">
</a>
<b style="color: inherit; margin-left: 8px;">Nginx 中文文档</b>
</div>
<div class="item">
<div>
<label for="version">版本</label>
<select id="version" onchange="onVersionChange(this)">
<option value="current" selected="selected">current</option>
</select>
</div>
<div style="margin-top: 8px;">
<label for="language">语言</label>
<select id="language" onchange="onLangChange(this)" value="zh">
<option value="en">English</option>
<option value="zh" selected="selected">中文</option>
</select>
</div>

</div>
<div class="item menus">
<a title="Table of Contents" style="margin-right: 8px;" href="index.html">
<i class="fa fa-chevron-left"></i>
<span style="margin-left: 2px;">返回目录</span>
</a>
</div>
<nav role="navigation" id="navigation">
<ul class="summary">
<li class="chapter"> <a href="install.html" title="Introduction"> Introduction </a>
<ul class="articles">
<li class="chapter"> <a href="install.html" title="Installing nginx"> Installing nginx </a> </li>
<li class="chapter"> <a href="configure.html" title="从源代码构建  Nginx"> 从源代码构建 Nginx </a> </li>
<li class="chapter"> <a href="beginners_guide.html" title="Beginner's Guide"> Beginner's Guide </a> </li>
<li class="chapter"> <a href="control.html" title="Controlling nginx"> Controlling nginx </a> </li>
<li class="chapter"> <a href="events.html" title="连接处理方法"> 连接处理方法 </a> </li>
<li class="chapter"> <a href="hash.html" title="设置哈希"> 设置哈希 </a> </li>
<li class="chapter"> <a href="debugging_log.html" title="调试日志"> 调试日志 </a> </li>
<li class="chapter"> <a href="syslog.html" title="记录到系统日志"> 记录到系统日志 </a> </li>
<li class="chapter"> <a href="syntax.html" title="配置文件测量单位"> 配置文件测量单位 </a> </li>
<li class="chapter"> <a href="switches.html" title="Command-line parameters"> Command-line parameters </a> </li>
<li class="chapter"> <a href="windows.html" title="Windows 版  Nginx"> Windows 版 Nginx </a> </li>
<li class="chapter"> <a href="http-request_processing.html" title="Nginx 如何处理请求"> Nginx 如何处理请求 </a> </li>
<li class="chapter"> <a href="http-server_names.html" title="Server names"> Server names </a> </li>
<li class="chapter"> <a href="http-load_balancing.html" title="使用  Nginx 作为  HTTP 负载均衡器"> 使用 Nginx 作为 HTTP 负载均衡器 </a> </li>
<li class="chapter"> <a href="http-configuring_https_servers.html" title="配置  HTTPS 服务器"> 配置 HTTPS 服务器 </a> </li>
<li class="chapter"> <a href="stream-stream_processing.html" title="Nginx 如何处理  TCP/UDP 会话"> Nginx 如何处理 TCP/UDP 会话 </a> </li>
<li class="chapter"> <a href="njs-index.html" title="用  njs 编写脚本"> 用 njs 编写脚本 </a> </li>
</ul> </li>
<li class="chapter"> <a href="howto_build_on_win32.html" title="How-To"> How-To </a>
<ul class="articles">
<li class="chapter"> <a href="howto_build_on_win32.html" title="使用  Visual C 在  Win32 平台上构建  Nginx"> 使用 Visual C 在 Win32 平台上构建 Nginx </a> </li>
<li class="chapter"> <a href="nginx_dtrace_pid_provider.html" title="使用  DTrace pid 提供程序调试  nginx"> 使用 DTrace pid 提供程序调试 nginx </a> </li>
<li class="chapter"> <a href="http-converting_rewrite_rules.html" title="转换重写规则"> 转换重写规则 </a> </li>
<li class="chapter"> <a href="http-websocket.html" title="WebSocket proxying"> WebSocket proxying </a> </li>
</ul> </li>
<li class="chapter"> <a href="contributing_changes.html" title="Development"> Development </a>
<ul class="articles">
<li class="chapter"> <a href="contributing_changes.html" title="Contributing Changes"> Contributing Changes </a> </li>
<li class="chapter"> <a href="dev-development_guide.html" title="Development guide"> Development guide </a> </li>
</ul> </li>
<li class="chapter"> <a href="dirindex.html" title="Modules reference"> Modules reference </a>
<ul class="articles">
<li class="chapter"> <a href="dirindex.html" title="指令的字母索引"> 指令的字母索引 </a> </li>
<li class="chapter"> <a href="varindex.html" title="变量按字母顺序索引"> 变量按字母顺序索引 </a> </li>
<li class="chapter"> <a href="ngx_core_module.html" title="Core functionality"> Core functionality </a> </li>
<li class="chapter"> <a href="http-ngx_http_core_module.html" title="ngx_http_core_module"> ngx_http_core_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_access_module.html" title="ngx_http_access_module"> ngx_http_access_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_addition_module.html" title="ngx_http_addition_module"> ngx_http_addition_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_api_module.html" title="ngx_http_api_module"> ngx_http_api_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_auth_basic_module.html" title="ngx_http_auth_basic_module"> ngx_http_auth_basic_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_auth_jwt_module.html" title="ngx_http_auth_jwt_module"> ngx_http_auth_jwt_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_auth_request_module.html" title="ngx_http_auth_request_module"> ngx_http_auth_request_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_autoindex_module.html" title="ngx_http_autoindex_module"> ngx_http_autoindex_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_browser_module.html" title="ngx_http_browser_module"> ngx_http_browser_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_charset_module.html" title="ngx_http_charset_module"> ngx_http_charset_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_dav_module.html" title="ngx_http_dav_module"> ngx_http_dav_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_empty_gif_module.html" title="ngx_http_empty_gif_module"> ngx_http_empty_gif_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_f4f_module.html" title="ngx_http_f4f_module"> ngx_http_f4f_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_fastcgi_module.html" title="ngx_http_fastcgi_module"> ngx_http_fastcgi_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_flv_module.html" title="ngx_http_flv_module"> ngx_http_flv_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_geo_module.html" title="ngx_http_geo_module"> ngx_http_geo_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_geoip_module.html" title="ngx_http_geoip_module"> ngx_http_geoip_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_grpc_module.html" title="ngx_http_grpc_module"> ngx_http_grpc_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_gunzip_module.html" title="ngx_http_gunzip_module"> ngx_http_gunzip_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_gzip_module.html" title="ngx_http_gzip_module"> ngx_http_gzip_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_gzip_static_module.html" title="ngx_http_gzip_static_module"> ngx_http_gzip_static_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_headers_module.html" title="ngx_http_headers_module"> ngx_http_headers_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_hls_module.html" title="ngx_http_hls_module"> ngx_http_hls_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_image_filter_module.html" title="ngx_http_image_filter_module"> ngx_http_image_filter_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_index_module.html" title="ngx_http_index_module"> ngx_http_index_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_js_module.html" title="ngx_http_js_module"> ngx_http_js_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_keyval_module.html" title="ngx_http_keyval_module"> ngx_http_keyval_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_limit_conn_module.html" title="ngx_http_limit_conn_module"> ngx_http_limit_conn_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_limit_req_module.html" title="ngx_http_limit_req_module"> ngx_http_limit_req_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_log_module.html" title="ngx_http_log_module"> ngx_http_log_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_map_module.html" title="ngx_http_map_module"> ngx_http_map_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_memcached_module.html" title="ngx_http_memcached_module"> ngx_http_memcached_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_mirror_module.html" title="ngx_http_mirror_module"> ngx_http_mirror_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_mp4_module.html" title="ngx_http_mp4_module"> ngx_http_mp4_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_perl_module.html" title="ngx_http_perl_module"> ngx_http_perl_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_proxy_module.html" title="ngx_http_proxy_module"> ngx_http_proxy_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_random_index_module.html" title="ngx_http_random_index_module"> ngx_http_random_index_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_realip_module.html" title="ngx_http_realip_module"> ngx_http_realip_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_referer_module.html" title="ngx_http_referer_module"> ngx_http_referer_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_rewrite_module.html" title="ngx_http_rewrite_module"> ngx_http_rewrite_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_scgi_module.html" title="ngx_http_scgi_module"> ngx_http_scgi_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_secure_link_module.html" title="ngx_http_secure_link_module"> ngx_http_secure_link_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_session_log_module.html" title="ngx_http_session_log_module"> ngx_http_session_log_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_slice_module.html" title="ngx_http_slice_module"> ngx_http_slice_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_spdy_module.html" title="ngx_http_spdy_module"> ngx_http_spdy_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_split_clients_module.html" title="ngx_http_split_clients_module"> ngx_http_split_clients_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_ssi_module.html" title="ngx_http_ssi_module"> ngx_http_ssi_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_ssl_module.html" title="ngx_http_ssl_module"> ngx_http_ssl_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_status_module.html" title="ngx_http_status_module"> ngx_http_status_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_stub_status_module.html" title="ngx_http_stub_status_module"> ngx_http_stub_status_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_sub_module.html" title="ngx_http_sub_module"> ngx_http_sub_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_upstream_module.html" title="ngx_http_upstream_module"> ngx_http_upstream_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_upstream_conf_module.html" title="ngx_http_upstream_conf_module"> ngx_http_upstream_conf_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_upstream_hc_module.html" title="ngx_http_upstream_hc_module"> ngx_http_upstream_hc_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_userid_module.html" title="ngx_http_userid_module"> ngx_http_userid_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_uwsgi_module.html" title="ngx_http_uwsgi_module"> ngx_http_uwsgi_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_v2_module.html" title="ngx_http_v2_module"> ngx_http_v2_module </a> </li>
<li class="chapter"> <a href="http-ngx_http_xslt_module.html" title="ngx_http_xslt_module"> ngx_http_xslt_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_core_module.html" title="ngx_mail_core_module"> ngx_mail_core_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_auth_http_module.html" title="ngx_mail_auth_http_module"> ngx_mail_auth_http_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_proxy_module.html" title="ngx_mail_proxy_module"> ngx_mail_proxy_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_ssl_module.html" title="ngx_mail_ssl_module"> ngx_mail_ssl_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_imap_module.html" title="ngx_mail_imap_module"> ngx_mail_imap_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_pop3_module.html" title="ngx_mail_pop3_module"> ngx_mail_pop3_module </a> </li>
<li class="chapter"> <a href="mail-ngx_mail_smtp_module.html" title="ngx_mail_smtp_module"> ngx_mail_smtp_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_core_module.html" title="ngx_stream_core_module"> ngx_stream_core_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_access_module.html" title="ngx_stream_access_module"> ngx_stream_access_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_geo_module.html" title="ngx_stream_geo_module"> ngx_stream_geo_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_geoip_module.html" title="ngx_stream_geoip_module"> ngx_stream_geoip_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_js_module.html" title="ngx_stream_js_module"> ngx_stream_js_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_keyval_module.html" title="ngx_stream_keyval_module"> ngx_stream_keyval_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_limit_conn_module.html" title="ngx_stream_limit_conn_module"> ngx_stream_limit_conn_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_log_module.html" title="ngx_stream_log_module"> ngx_stream_log_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_map_module.html" title="ngx_stream_map_module"> ngx_stream_map_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_proxy_module.html" title="ngx_stream_proxy_module"> ngx_stream_proxy_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_realip_module.html" title="ngx_stream_realip_module"> ngx_stream_realip_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_return_module.html" title="ngx_stream_return_module"> ngx_stream_return_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_split_clients_module.html" title="ngx_stream_split_clients_module"> ngx_stream_split_clients_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_ssl_module.html" title="ngx_stream_ssl_module"> ngx_stream_ssl_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_ssl_preread_module.html" title="ngx_stream_ssl_preread_module"> ngx_stream_ssl_preread_module </a> </li>
<li class="chapter"> <a href="" title="ngx_stream_upstream_module"> ngx_stream_upstream_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_upstream_hc_module.html" title="ngx_stream_upstream_hc_module"> ngx_stream_upstream_hc_module </a> </li>
<li class="chapter"> <a href="stream-ngx_stream_zone_sync_module.html" title="ngx_stream_zone_sync_module"> ngx_stream_zone_sync_module </a> </li>
<li class="chapter"> <a href="ngx_google_perftools_module.html" title="ngx_google_perftools_module"> ngx_google_perftools_module </a> </li>
</ul> </li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<header class="book-header">
<div class="dropdown pull-right js-toolbar-action">
<a class="btn toggle-dropdown" aria-label="Language" href="#">
<i class="fa fa-globe"></i>
</a>
<div class="dropdown-menu dropdown-left">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<button class="button size-1" onclick="changeLang('zh_CN')">中文</button>
</div>
<div class="buttons">
<button class="button size-1" onclick="changeLang('en_US')">English</button>
</div>
</div>
</div>
<a class="btn pull-right js-toolbar-action non-mobile" aria-label="Sign up" href="register.html">
<i class="fa fa-sign-in"></i> <span>注册</span>
</a>
<a class="btn pull-right js-toolbar-action non-mobile" aria-label="Sign in" href="register.html">
<i class="fa fa-sign-in"></i>
<span>登录</span>
</a>
<a class="btn pull-left js-toolbar-action btn-summary" href="#"><i class="fa fa-align-justify"></i></a>
<div class="dropdown pull-left font-settings js-toolbar-action">
<a class="btn toggle-dropdown" aria-label="Font Settings" href="#">
<i class="fa fa-font"></i>
</a>
<div class="dropdown-menu dropdown-right">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<button class="button size-2 font-reduce">A</button>
<button class="button size-2 font-enlarge">A</button>
</div>
<div class="buttons">
<button class="button size-2 family-serif">Serif</button>
<button class="button size-2 family-sans">Sans</button>
</div>
<div class="buttons">
<button class="button size-3 theme-white">White</button>
<button class="button size-3 theme-sepia">Sepia</button>
<button class="button size-3 theme-night">Night</button>
</div>
</div>
</div>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Home" href="zh.html">
<i class="fa fa-home"></i> <span>首页</span>
</a>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Guide" href="javascript:window.open('https://www.javadoc.org/');">
<i class="fa fa-book"></i> <span>API Docs</span>
</a>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Tools" href="index1.html">
<i class="fa fa-gears"></i> <span>工具</span>
</a>
<div class="dropdown pull-left js-toolbar-action mobile">
<a class="btn toggle-dropdown" aria-label="Language" href="#">
<i class="fa fa-chevron-down"></i>
</a>
<div class="dropdown-menu dropdown-right">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<a class="button size-1" aria-label="Home" href="zh.html">
<i class="fa fa-home"></i> <span>首页</span>
</a>
</div>
<div class="buttons">
<a class="button size-1" aria-label="Guide" href="javascript:window.open('https://www.javadoc.org/');">
<i class="fa fa-book"></i> <span>API Docs</span>
</a>
</div>
<div class="buttons">
<a class="button size-1" aria-label="Tools" href="index1.html">
<i class="fa fa-gears"></i> <span>工具</span>
</a>
</div>
</div>
</div>
<div id="autocomplete" class="pull-right"></div>
<span id="toolbar-title"></span>
</header>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal markdown-section">
<div id="content">
<h1>Module ngx_stream_upstream_module</h1>
<div><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6108808167664152" data-ad-slot="6964403648"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
<div><ul>
<li><a href="#example">Example Configuration</a></li>
<li><a href="#directives">Directives</a>
<ul>
<li><a href="#upstream">upstream</a></li>
<li><a href="#server">server</a></li>
<li><a href="#zone">zone</a></li>
<li><a href="#state">state</a></li>
<li><a href="#hash">hash</a></li>
<li><a href="#least_conn">least_conn</a></li>
<li><a href="#least_time">least_time</a></li>
<li><a href="#random">random</a></li>
<li><a href="#resolver">resolver</a></li>
<li><a href="#resolver_timeout">resolver_timeout</a></li>
</ul>
</li>
<li><a href="#variables">Embedded Variables</a><br><a href="" id="summary"></a></li>
</ul>
<p><code>ngx_stream_upstream_module</code>模块(1.9.0)用于定义可由<a href="stream-ngx_stream_proxy_module.html#proxy_pass">proxy_pass</a>指令引用的服务器组。</p>
<p><a href="" id="example"></a></p>
<h4 id="example-configuration"><a href="#example-configuration" id="example-configuration"></a>Example Configuration</h4>
<pre><code class="hljs language-shell">upstream backend {
    hash $remote_addr consistent;

    server backend1.example.com:12345  weight=5;
    server backend2.example.com:12345;
    server unix:/tmp/backend3;

    server backup1.example.com:12345   backup;
    server backup2.example.com:12345   backup;
}

server {
    listen 12346;
    proxy_pass backend;
}
</code></pre>
<p>周期性<a href="stream-ngx_stream_upstream_hc_module.html">health checks</a>的动态可配置组可作为我们<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用：</p>
<pre><code class="hljs language-shell">resolver 10.0.0.1;

upstream dynamic {
    zone upstream_dynamic 64k;

    server backend1.example.com:12345 weight=5;
    server backend2.example.com:12345 fail_timeout=5s slow_start=30s;
    server 192.0.2.1:12345            max_fails=3;
    server backend3.example.com:12345 resolve;
    server backend4.example.com       service=http resolve;

    server backup1.example.com:12345  backup;
    server backup2.example.com:12345  backup;
}

server {
    listen 12346;
    proxy_pass dynamic;
    health_check;
}
</code></pre>
<p><a href="" id="directives"></a></p>
<h4 id="directives"><a href="#directives" id="directives"></a>Directives</h4>
<p><a href="" id="upstream"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>upstream name { ... }</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>stream</code></td></tr>
</tbody>
</table>
<p>定义一组服务器。服务器可以在不同的端口上侦听。此外，可以混合使用侦听 TCP 和 UNIX 域套接字的服务器。</p>
<p>Example:</p>
<pre><code class="hljs language-shell">upstream backend {
    server backend1.example.com:12345 weight=5;
    server 127.0.0.1:12345            max_fails=3 fail_timeout=30s;
    server unix:/tmp/backend2;
    server backend3.example.com:12345 resolve;

    server backup1.example.com:12345  backup;
}
</code></pre>
<p>默认情况下，使用加权循环平衡方法在服务器之间分配连接。在上面的示例中，每个 7 个连接将如下分配：5 个连接转到<code>backend1.example.com:12345</code>，一个连接到第二个和第三个服务器。如果在与服务器通信期间发生错误，则连接将被传递到下一个服务器，依此类推，直到尝试所有正常运行的服务器为止。如果与所有服务器的通信失败，则连接将关闭。</p>
<p><a href="" id="server"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>server address [parameters];</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>定义服务器的<code>address</code>和其他<code>parameters</code>。该地址可以指定为带有强制端口的域名或 IP 地址，也可以指定为在“ <code>unix:</code>”前缀之后指定的 UNIX 域套接字路径。解析为多个 IP 地址的域名一次定义了多个服务器。</p>
<p>可以定义以下参数：</p>
<h4 id="weight-number"><a href="#weight" id="weight"></a> weight= number</h4>
<ul>
<li>设置服务器的权重，默认情况下为 1.</li>
</ul>
<h4 id="max-conns-number"><a href="#max_conns" id="max_conns"></a> max_conns= number</h4>
<ul>
<li>限制到代理服务器的同时连接的最大<code>number</code>(1.11.5)。默认值为零，表示没有限制。如果服务器组不在<a href="#zone">shared memory</a>中，则此限制在每个工作进程中均有效。</li>
</ul>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>在 1.11.5 版之前，此参数可作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用。</p>
</div></div>
<h4 id="max-fails-number"><a href="#max_fails" id="max_fails"></a> max_fails= number</h4>
<ul>
<li>设置在<code>fail_timeout</code>参数设置的持续时间内应与服务器通信失败的尝试次数，以认为服务器在<code>fail_timeout</code>参数设置的持续时间内不可用。默认情况下，未成功尝试的次数设置为 1.零值将禁用对尝试的记帐。在这里，不成功的尝试是与服务器构建连接时出现错误或超时。</li>
</ul>
<h4 id="fail-timeout-time"><a href="#fail_timeout" id="fail_timeout"></a> fail_timeout= time</h4>
<ul>
<li>
<p>sets</p>
</li>
<li>
<p>在指定次数的不成功尝试与服务器通信的时间范围内，应考虑服务器不可用；</p>
</li>
<li>
<p>以及服务器将不可用的时间段。</p>
</li>
</ul>
<p>默认情况下，该参数设置为 10 秒。</p>
<h4 id="backup"><a href="#backup" id="backup"></a> backup</h4>
<ul>
<li>将服务器标记为备份服务器。当主服务器不可用时，将传递到备份服务器的连接。</li>
</ul>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>该参数不能与<a href="#hash">hash</a>和<a href="#random">random</a>负载平衡方法一起使用。</p>
</div></div>
<h4 id="down"><a href="#down" id="down"></a> down</h4>
<ul>
<li>将服务器标记为永久不可用。</li>
</ul>
<p>此外，以下参数是我们的<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分：</p>
<h4 id="resolve"><a href="#resolve" id="resolve"></a> resolve</h4>
<ul>
<li>监视与服务器域名对应的 IP 地址的更改，并自动修改上游配置，而无需重新启动 nginx。服务器组必须位于<a href="#zone">shared memory</a>中。</li>
</ul>
<p>为了使该参数起作用，必须在<a href="stream-ngx_stream_core_module.html#resolver">stream</a>块或相应的<a href="#resolver">upstream</a>块中指定<code>resolver</code>指令。</p>
<h4 id="service-name"><a href="#service" id="service"></a> service= name</h4>
<ul>
<li>启用 DNS <a href="javascript:window.open('https://tools.ietf.org/html/rfc2782');" target="_blank" rel="noopener noreferrer">SRV</a>记录的解析并设置服务<code>name</code>(1.9.13)。为了使此参数起作用，必须为服务器指定<a href="#resolve">resolve</a>参数，并指定不带端口号的主机名。</li>
</ul>
<p>如果服务名称不包含点(“ <code>.</code>”)，则将构建<a href="javascript:window.open('https://tools.ietf.org/html/rfc2782');" target="_blank" rel="noopener noreferrer">RFC</a>兼容名称，并将 TCP 协议添加到服务前缀。例如，要查找<code>_http._tcp.backend.example.com</code> SRV 记录，必须指定指令：</p>
<pre><code class="hljs language-shell">server backend.example.com service=http resolve;
</code></pre>
<p>如果服务名称包含一个或多个点，则通过将服务前缀和服务器名称结合在一起来构造名称。例如，要查找<code>_http._tcp.backend.example.com</code>和<code>server1.backend.example.com</code> SRV 记录，必须指定指令：</p>
<pre><code class="hljs language-shell">server backend.example.com service=_http._tcp resolve;
server example.com service=server1.backend resolve;
</code></pre>
<p>最高优先级的 SRV 记录(具有相同的最低优先级值的记录)被解析为主服务器，其余的 SRV 记录被解析为备用服务器。如果为服务器指定了<a href="#backup">backup</a>参数，则将高优先级 SRV 记录解析为备份服务器，其余的 SRV 记录将被忽略。</p>
<h4 id="slow-start-time"><a href="#slow_start" id="slow_start"></a> slow_start= time</h4>
<ul>
<li>设置<code>time</code>，当不正常的服务器变为<a href="stream-ngx_stream_upstream_hc_module.html#health_check">healthy</a>或在一段时间后服务器变为<a href="#fail_timeout">unavailable</a>可用时，服务器会将其重量从零恢复到标称值。默认值为零，即禁用慢速启动。</li>
</ul>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>该参数不能与<a href="#hash">hash</a>和<a href="#random">random</a>负载平衡方法一起使用。</p>
</div></div><div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>如果组中只有一台服务器，则<code>max_fails</code>，<code>fail_timeout</code>和<code>slow_start</code>参数将被忽略，并且永远不会认为该服务器不可用。</p>
</div></div>
<p><a href="" id="zone"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>zone name [size];</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>定义共享内存区域的<code>name</code>和<code>size</code>，该区域保留工作进程之间共享的组的配置和运行时状态。几个组可以共享同一区域。在这种情况下，仅指定一次<code>size</code>就足够了。</p>
<p>另外，作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分，此类组允许更改组成员身份或修改特定服务器的设置，而无需重新启动 nginx。可通过<a href="http-ngx_http_api_module.html">API</a>模块(1.13.3)访问该配置。</p>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>在 1.13.3 版之前，只能通过<a href="http-ngx_http_upstream_conf_module.html#upstream_conf">upstream_conf</a>处理的特殊位置访问该配置。</p>
</div></div>
<p><a href="" id="state"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>state file;</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>该指令出现在 1.9.7 版中。</p>
<p>指定一个<code>file</code>，以保留动态可配置组的状态。</p>
<p>Examples:</p>
<pre><code class="hljs language-shell">state /var/lib/nginx/state/servers.conf; # path for Linux
state /var/db/nginx/state/servers.conf;  # path for FreeBSD
</code></pre>
<p>当前状态仅限于带有参数的服务器列表。解析配置时会读取该文件，并且每次上游配置为<a href="http-ngx_http_api_module.html#stream_upstreams_stream_upstream_name_servers_">changed</a>时都会更新该文件。应避免直接更改文件内容。该指令不能与<a href="#server">server</a>指令一起使用。</p>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>在<a href="control.html#reconfiguration">configuration reload</a>或<a href="control.html#upgrade">binary upgrade</a>期间所做的更改可能会丢失。</p>
</div></div><div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>该指令可作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用。</p>
</div></div>
<p><a href="" id="hash"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>hash key [consistent];</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>指定服务器组的负载平衡方法，其中客户端-服务器映射基于散列的<code>key</code>值。 <code>key</code>可以包含文本，变量及其组合(1.11.2)。用法示例：</p>
<pre><code class="hljs language-shell">hash $remote_addr;
</code></pre>
<p>请注意，从组中添加或删除服务器可能会导致将大多数密钥重新映射到其他服务器。该方法与<a href="javascript:window.open('https://metacpan.org/pod/Cache::Memcached');" target="_blank" rel="noopener noreferrer">Cache::Memcached</a> Perl 库兼容。</p>
<p>如果指定了<code>consistent</code>参数，则将使用<a href="javascript:window.open('https://www.metabrew.com/article/libketama-consistent-hashing-algo-memcached-clients');" target="_blank" rel="noopener noreferrer">ketama</a>一致的哈希方法。该方法可确保在将服务器添加到组中或从组中删除服务器时，只有很少的键将被重新映射到不同的服务器。这有助于为缓存服务器实现更高的缓存命中率。该方法与<code>ketama_points</code>参数设置为 160 的<a href="javascript:window.open('https://metacpan.org/pod/Cache::Memcached::Fast');" target="_blank" rel="noopener noreferrer">Cache::Memcached::Fast</a> Perl 库兼容。</p>
<p><a href="" id="least_conn"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>least_conn;</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>指定组应使用负载平衡方法，其中将连接传递到活动连接数最少的服务器，同时要考虑服务器的权重。如果有多个这样的服务器，则依次使用加权循环平衡方法进行尝试。</p>
<p><a href="" id="least_time"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>least_time connect | first_byte | last_byte [inflight];</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>指定组应使用负载平衡方法，其中将连接传递到服务器的平均时间最少且活动连接的数量最少，同时要考虑服务器的权重。如果有多个这样的服务器，则依次使用加权循环平衡方法进行尝试。</p>
<p>如果指定了<code>connect</code>参数，则使用到上游服务器<a href="#var_upstream_connect_time">connect</a>的时间。如果指定了<code>first_byte</code>参数，则使用接收<a href="#var_upstream_first_byte_time">first byte</a>数据的时间。如果指定了<code>last_byte</code>，则使用接收<a href="#var_upstream_session_time">last byte</a>数据的时间。如果指定了<code>inflight</code>参数(1.11.6)，则还将考虑不完整的连接。</p>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>在 1.11.6 版之前，默认情况下会考虑不完整的连接。</p>
</div></div><div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>该指令可作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用。</p>
</div></div>
<p><a href="" id="random"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>random [two [method]];</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>该指令出现在 1.15.1 版中。</p>
<p>指定组应使用负载平衡方法，其中将连接传递到随机选择的服务器，同时要考虑服务器的权重。</p>
<p>可选的<code>two</code>参数指示 nginx 随机选择<a href="static/file/balls.pdf" target="_blank" rel="noopener noreferrer">two</a>个服务器，然后使用指定的<code>method</code>选择一个服务器。默认方法是<code>least_conn</code>，它将连接传递到活动连接数最少的服务器。</p>
<p><a href="" id="random_least_time"></a></p>
<p><code>least_time</code>方法将连接以最少的平均时间和最少的活动连接数传递给服务器。如果指定了<code>least_time=connect</code>参数，则使用到上游服务器<a href="#var_upstream_connect_time">connect</a>的时间。如果指定了<code>least_time=first_byte</code>参数，则使用接收<a href="#var_upstream_first_byte_time">first byte</a>数据的时间。如果指定<code>least_time=last_byte</code>，则使用接收<a href="#var_upstream_session_time">last byte</a>数据的时间。</p>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p><code>least_time</code>方法可作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用。</p>
</div></div>
<p><a href="" id="resolver"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>resolver address ... [valid=time] [ipv6=on|off] [status_zone=zone];</code></td></tr>
<tr><td>Default:</td><td>—</td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>该指令出现在 1.17.5 版中。</p>
<p>配置用于将上游服务器的名称解析为地址的名称服务器，例如：</p>
<pre><code class="hljs language-shell">resolver 127.0.0.1 [::1]:5353;
</code></pre>
<p>可以使用可选端口将地址指定为域名或 IP 地址。如果未指定端口，则使用端口 53.以循环方式查询名称服务器。</p>
<p><a href="" id="resolver_ipv6"></a></p>
<p>默认情况下，nginx 在解析时将同时查找 IPv4 和 IPv6 地址。如果不需要查找 IPv6 地址，则可以指定<code>ipv6=off</code>参数。</p>
<p><a href="" id="resolver_valid"></a></p>
<p>默认情况下，nginx 使用响应的 TTL 值缓存答案。可选的<code>valid</code>参数允许覆盖它：</p>
<pre><code class="hljs language-shell">resolver 127.0.0.1 [::1]:5353 valid=30s;
</code></pre>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>为防止 DNS 欺骗，建议在适当安全的受信任本地网络中配置 DNS 服务器。</p>
</div></div>
<p><a href="" id="resolver_status_zone"></a></p>
<p>可选的<code>status_zone</code>参数启用<code>zone</code>中指定请求和响应的 DNS 服务器统计信息的<a href="http-ngx_http_api_module.html#resolvers_">collection</a>。</p>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>该指令可作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用。</p>
</div></div>
<p><a href="" id="resolver_timeout"></a></p>
<table>
<thead></thead>
<tbody>
<tr><td>Syntax:</td><td><code>resolver_timeout time;</code></td></tr>
<tr><td>Default:</td><td><code>resolver_timeout 30s;</code></td></tr>
<tr><td>Context:</td><td><code>upstream</code></td></tr>
</tbody>
</table>
<p>该指令出现在 1.17.5 版中。</p>
<p>设置名称解析超时，例如：</p>
<pre><code class="hljs language-shell">resolver_timeout 5s;
</code></pre>
<div class="alert callout info"><p class="title"><i class="fa fa-info-circle"></i>Note</p><div><p>该指令可作为<a href="javascript:window.open('https://nginx.com/products/');" target="_blank" rel="noopener noreferrer">commercial subscription</a>的一部分使用。</p>
</div></div>
<p><a href="" id="variables"></a></p>
<h4 id="embedded-variables"><a href="#embedded-variables" id="embedded-variables"></a>Embedded Variables</h4>
<p><code>ngx_stream_upstream_module</code>模块支持以下嵌入式变量：</p>
<h4 id="upstream-addr"><a href="#var_upstream_addr" id="var_upstream_addr"></a> $upstream_addr</h4>
<ul>
<li>保留 IP 地址和端口，或到上游服务器的 UNIX 域套接字(1.11.4)的路径。如果在代理过程中联系了多个服务器，则它们的地址之间用逗号分隔，例如“ <code>192.168.1.1:12345, 192.168.1.2:12345, unix:/tmp/sock</code>”。如果无法选择服务器，则变量将保留服务器组的名称。</li>
</ul>
<h4 id="upstream-bytes-received"><a href="#var_upstream_bytes_received" id="var_upstream_bytes_received"></a> $upstream_bytes_received</h4>
<ul>
<li>从上游服务器收到的字节数(1.11.4)。来自多个连接的值用逗号分隔，例如<a href="#var_upstream_addr">$upstream_addr</a>变量中的地址。</li>
</ul>
<h4 id="upstream-bytes-sent"><a href="#var_upstream_bytes_sent" id="var_upstream_bytes_sent"></a> $upstream_bytes_sent</h4>
<ul>
<li>发送到上游服务器的字节数(1.11.4)。来自多个连接的值用逗号分隔，例如<a href="#var_upstream_addr">$upstream_addr</a>变量中的地址。</li>
</ul>
<h4 id="upstream-connect-time"><a href="#var_upstream_connect_time" id="var_upstream_connect_time"></a> $upstream_connect_time</h4>
<ul>
<li>连接上游服务器的时间(1.11.4)；时间以毫秒为单位，以秒为单位。多个连接的时间用逗号分隔，例如<a href="#var_upstream_addr">$upstream_addr</a>变量中的地址。</li>
</ul>
<h4 id="upstream-first-byte-time"><a href="#var_upstream_first_byte_time" id="var_upstream_first_byte_time"></a> $upstream_first_byte_time</h4>
<ul>
<li>接收数据的第一个字节的时间(1.11.4)；时间以毫秒为单位，以秒为单位。多个连接的时间用逗号分隔，例如<a href="#var_upstream_addr">$upstream_addr</a>变量中的地址。</li>
</ul>
<h4 id="upstream-session-time"><a href="#var_upstream_session_time" id="var_upstream_session_time"></a> $upstream_session_time</h4>
<ul>
<li>会话持续时间，以毫秒为单位，以毫秒为单位(1.11.4)。多个连接的时间用逗号分隔，例如<a href="#var_upstream_addr">$upstream_addr</a>变量中的地址。</li>
</ul>
</div>
</div>
</section>
<div class="right-sidebar">
<div class="affix"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6108808167664152" data-ad-slot="3102929424" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
</div>
</div>
<div class="ft">
<a href="#toolbar-title" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a>
<footer class="footer">
<div class="footer__container--normal">
<img alt="扫码关注公众号" title="扫码关注公众号" src="static/picture/qr-code.png" width="170" height="170">
<div class="footer__description--normal">
<p class="paragraph footer__author--normal">Docs4dev<sup class="super">&#xAE;</sup>
</p>
<p class="paragraph footer__quote&#45;&#45;normal">
如果你在使用过程中遇到任何问题，可以在 <a href="javascript:window.open('https://github.com/docs4dev/docs4dev-issues');" target="_blank" rel="noopener noreferrer">这里<i class="fa fa-external-link"></i></a> 提issue。
</p>
<div class="footer__main--normal">
<p class="paragraph footer__main__paragraph--normal copyright" style="color: #666 !important;">
<a href="javascript:window.open('https://beian.miit.gov.cn/');">
蜀ICP备14021783号-6
</a>
</p>
<p class="paragraph footer__main__paragraph--normal copyright" style="color: #666 !important;">
Copyright &#xA9; Docs4dev all
right reserved, powered by <a href="index2.html" target="_blank">Docs4dev</a></p>
</div>
</div>
</div>
<div class="box__issues">
</div>
</footer>
</div>
</div>
</div>
</div>
</div>
<script>
  var hasToc = true;
  /*  var downloadable = /!*false*!/ false;
    var editable = /!*false*!/ false;
    var code = /!*"nginx"*!/ false;
    var version = /!*"current"*!/ false;
    var type = /!*"reference"*!/ false;
    var lang = /!*"zh"*!/ 'en';
    //edit link
    require(["gitbook", "jQuery"], function (gitbook, $) {
      gitbook.events.bind('start', function (e, config) {
        // Add edit toolbar to left
        var chapterId = /!*17750*!/ 0;
        if (downloadable) {
          gitbook.toolbar.createButton({
            icon: 'fa fa-download',
            text: '下载',
            onClick: function () {
              window.open('/download?code=' + code + '&version=' + version + '&type=' + type + '&lang=' + lang);
            }
          });
        }
        if (editable) {
          gitbook.toolbar.createButton({
            icon: 'fa fa-edit',
            text: '编辑此页',
            onClick: function () {
              window.open('/docs/edit?chapterId=' + chapterId + '&lang=' + lang);
            }
          });
        }
      });
    });*/
</script>
<script>
    var code = "nginx";
    var lang = "zh";
  </script>

<script src="static/js/autocomplete-js.js"></script>
<script src="static/js/app.min.js"></script>
<script src="static/js/search.min.js"></script>
</body>
</html>
